namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
namespace hr = "http://eric.van-der-vlist.com/ns/person"
namespace local = ""
default namespace ns1 = "http://eric.van-der-vlist.com/ns/library"
namespace sn = "http://www.snee.com/ns/stages"

start =
  ((element library { book-element+ }
    | book-element)
   | author-element)
  | character-element
foreign-elements =
  element * - ((local:* | ns1:*) | hr:*) { anything }+
  | empty
foreign-attributes =
  attribute * - ((local:* | ns1:*) | hr:*) { text }+
  | empty
anything =
  ((element * { anything }
    | attribute * { text })
   | text)+
  | empty
foreign-nodes = (foreign-attributes | foreign-elements)+ | empty
author-element =
  element hr:author {
    ((attribute id {
        xsd:NMTOKEN { maxLength = " 16 " }
      },
      name-element),
     born-element),
    (dead-element | empty)
  }
book-content =
  (((((attribute id { text },
       attribute available { available-content }),
      isbn-element),
     title-element),
    (author-element+ | empty)),
   (character-element+ | empty))
  & foreign-nodes
book-element = element book { book-content }
born-element = element hr:born { xsd:date }
character-element =
  grammar {
    start =
      element character {
        ((attribute id { text },
          parent name-element),
         parent born-element),
        parent qualification-element
      }
  }
dead-element = element hr:dead { xsd:date }
isbn-element = element isbn { foreign-attributes, token }
name-element = element hr:name { xsd:token }
qualification-element = element qualification { text }
title-element = element title { foreign-attributes, text }
available-content = ("true" | xsd:token " false ") | " "
